package com.hcc.gateway.netty.support;

import com.hcc.gateway.netty.context.GatewayExchange;

/**
 * GatewayExchangeUtils
 *
 * @author shengjun.hu
 * @date 2021/12/31
 */
public class GatewayExchangeUtils {

    private GatewayExchangeUtils() {}

    public static void setAlreadyRoute(GatewayExchange exchange) {
        exchange.addAttribute(GatewayConstants.GATEWAY_REQUEST_URI_ATTR, true);
    }

    public static boolean isAlreadyRoute(GatewayExchange exchange) {
        Boolean alreadyRoute = exchange.getAttributeByName(GatewayConstants.GATEWAY_REQUEST_URI_ATTR, Boolean.class);
        if (alreadyRoute == null) {
            return false;
        }

        return alreadyRoute;
    }

}
